package com.lecyon.farm.common.exception;

import com.lecyon.farm.common.api.ResponseCodeI18n;
import lombok.Data;

/**
 * @author Yao Zheng
 * @Description: 自定义数据库操作异常
 * @Date 2019/8/9 10:37
 */
@Data
public class DbOperationException extends RuntimeException {

    private static final long serialVersionUID = 2684099760669375847L;

    /**
     * 异常编码
     */
    private int code;

    /**
     * 异常信息
     */
    private String message;

    public DbOperationException() {
        super();
    }

    public DbOperationException(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public DbOperationException(String message) {
        this.message = message;
    }


    public DbOperationException(ResponseCodeI18n responseCodeI18n) {
        this.code = responseCodeI18n.getCode();
        this.message = responseCodeI18n.getMsg();
    }
}
